package com.sphd.beautysalon.adapters;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sphd.beautysalon.info.ApplyForInfo;
import com.sphd.beautysalon.R;
import com.sphd.beautysalon.utils.Constant;
import com.wzh.frame.utils.BigDisMailUtils;
import com.wzh.frame.utils.StringUtils;
import com.wzh.frame.utils.TimeUtils;

import java.util.List;

/**
 * Created by Hu on 2017/1/4.
 */

public class ApplyForAdapter extends BaseQuickAdapter<ApplyForInfo> {
    int type, pos;
    Context context;

    public ApplyForAdapter(int layoutResId, List<ApplyForInfo> data, Context context) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ApplyForInfo applyForInfo) {
          /*分析type的值 如果是1 为投资  0为撤资 3为 个人资金*/
        if (type == 3) {
            if (applyForInfo.getApply_type() == 1) {
                baseViewHolder.setText(R.id.i_name, "投入申请");
                TextView textView = baseViewHolder.getView(R.id.i_re_money);
                textView.setTextColor(context.getResources().getColor(R.color.indigo_500));
//                baseViewHolder.getView(R.id.i_reason).setVisibility(View.INVISIBLE);
                baseViewHolder.setText(R.id.i_re_money, BigDisMailUtils.turnTrim(applyForInfo.getApply_money(), Constant.DECIMAL_POINT_TWO));
                baseViewHolder.setText(R.id.i_re_time, "申请时间:" +
                        TimeUtils.getTime(applyForInfo.getApply_regtime(), TimeUtils.DATE_FORMAT_NO_TRIM));
                baseViewHolder.setText(R.id.i_account_money, "当前资金:" + BigDisMailUtils.turnTrim(applyForInfo.getSum_account(), Constant.DECIMAL_POINT_TWO));
                baseViewHolder.getView(R.id.layout_item).setBackgroundColor(context.getResources().getColor(R.color.white));
            } else {
                baseViewHolder.setText(R.id.i_name, "撤资申请");
                TextView textView = baseViewHolder.getView(R.id.i_re_money);
                textView.setTextColor(context.getResources().getColor(R.color.black));
//                baseViewHolder.getView(R.id.i_reason).setVisibility(View.INVISIBLE);
                baseViewHolder.setText(R.id.i_re_money, BigDisMailUtils.turnTrim(applyForInfo.getApply_money(), Constant.DECIMAL_POINT_TWO));
                baseViewHolder.setText(R.id.i_re_time, "申请时间:" +
                        TimeUtils.getTime(applyForInfo.getApply_regtime(), TimeUtils.DATE_FORMAT_NO_TRIM));
                baseViewHolder.setText(R.id.i_account_money, "当前资金:" + BigDisMailUtils.turnTrim(applyForInfo.getSum_account(), Constant.DECIMAL_POINT_TWO));

                if (applyForInfo.getApply_status() == 3) {
                    baseViewHolder.getView(R.id.layout_item).setBackgroundColor(context.getResources().getColor(R.color.my_gray));
                } else {
                    baseViewHolder.getView(R.id.layout_item).setBackgroundColor(context.getResources().getColor(R.color.white));
                }

            }

            if (pos == 2) {
                baseViewHolder.setText(R.id.i_reason, StringUtils.isEmpty(applyForInfo.getRatify_remark()) ? "" : applyForInfo.getRatify_remark());
            }
        } else {
            baseViewHolder.setText(R.id.i_name, applyForInfo.getApply_name());
            baseViewHolder.setText(R.id.i_re_time, "申请时间:" + TimeUtils.getTime(applyForInfo.getApply_regtime(), TimeUtils.DATE_FORMAT_NO_TRIM));
            baseViewHolder.setText(R.id.i_account_money, "当前资金:" + BigDisMailUtils.turnTrim(applyForInfo.getSum_account(), Constant.DECIMAL_POINT_TWO));
            baseViewHolder.getView(R.id.i_reason).setVisibility(View.INVISIBLE);
            baseViewHolder.setText(R.id.i_re_money, BigDisMailUtils.turnTrim(applyForInfo.getApply_money(), Constant.DECIMAL_POINT_TWO));
        }
    }

    public void setType(int type, int pos) {
        this.type = type;
        this.pos = pos;
    }
}

